Skip to contentSkip to conversation

Change in openvpn[master]: dco-freebsd: store peer stats directly in c2

Openvpn-devel Superseded ralf_lici (Code Review) 3 participants 13 messages Oct 15, 2025 – Oct 19, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1760513121000.I53dd40fabdeacb9dca843e28fdd3b357711c5a84@...2715...

#1 lore raw

Attention is currently required from: flichtenheld, plaisthos.

Hello plaisthos, flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1275?usp=email

to review the following change.

Change subject: dco-freebsd: store peer stats directly in c2
......................................................................

dco-freebsd: store peer stats directly in c2

The dco_context_t structure includes a reference to the general context structure c, which allows us to store dco_read_bytes and dco_write_bytes directly as c2 fields. This aligns the FreeBSD implementation with how we handle DCO peer stats on Linux and Windows.

Change-Id I53dd40fabdeacb9dca843e28fdd3b357711c5a84

---
M src/openvpn/dco_freebsd.c

1 file changed, 2 insertions(+), 2 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/75/1275/1

src/openvpn/dco_freebsd.c +2 -2
index b9f6bc7..5791257 100644
@@ -621,8 +621,8 @@
             {
                 const nvlist_t *bytes = nvlist_get_nvlist(nvl, "bytes");
 
-                dco->dco_read_bytes = nvlist_get_number(bytes, "in");
-                dco->dco_write_bytes = nvlist_get_number(bytes, "out");
+                dco->c->c2.dco_read_bytes = nvlist_get_number(bytes, "in");
+                dco->c->c2.dco_write_bytes = nvlist_get_number(bytes, "out");
             }
 
             dco->dco_message_type = OVPN_CMD_DEL_PEER;

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1275?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I53dd40fabdeacb9dca843e28fdd3b357711c5a84
Gerrit-Change-Number: 1275
Gerrit-PatchSet: 1
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>

#2 lore raw

LGTM.

—
Kristof

Quoted 74 lines · ralf_lici (Code Review)

Attention is currently required from: flichtenheld, plaisthos.

Hello plaisthos, flichtenheld,

I'd like you to do a code review.
Please visit

http://gerrit.openvpn.net/c/openvpn/+/1275?usp=email

to review the following change.

Change subject: dco-freebsd: store peer stats directly in c2
......................................................................

dco-freebsd: store peer stats directly in c2

The dco_context_t structure includes a reference to the general context structure c, which allows us to store dco_read_bytes and dco_write_bytes directly as c2 fields. This aligns the FreeBSD implementation with how we handle DCO peer stats on Linux and Windows.

Change-Id I53dd40fabdeacb9dca843e28fdd3b357711c5a84

---
M src/openvpn/dco_freebsd.c

1 file changed, 2 insertions(+), 2 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn
refs/changes/75/1275/1

src/openvpn/dco_freebsd.c +2 -2
index b9f6bc7..5791257 100644
@@ -621,8 +621,8 @@
             {
                 const nvlist_t *bytes = nvlist_get_nvlist(nvl, 
 "bytes");
 
-                dco->dco_read_bytes = nvlist_get_number(bytes, "in");
-                dco->dco_write_bytes = nvlist_get_number(bytes, 
 "out");
+                dco->c->c2.dco_read_bytes = nvlist_get_number(bytes, 
 "in");
+                dco->c->c2.dco_write_bytes = nvlist_get_number(bytes, 
"out");
             }

             dco->dco_message_type = OVPN_CMD_DEL_PEER;
Signature · 20 lines
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1275?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I53dd40fabdeacb9dca843e28fdd3b357711c5a84
Gerrit-Change-Number: 1275
Gerrit-PatchSet: 1
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
#3 lore raw

PATCH v2 1/1 dco-freebsd: store peer stats directly in c2

In reply to a message not in the archive

From: Ralf Lici <[email protected]...>

The dco_context_t structure includes a reference to the general context structure c, which allows us to store dco_read_bytes and dco_write_bytes directly as c2 fields. This aligns the FreeBSD implementation with how we handle DCO peer stats on Linux and Windows.

Change-Id I53dd40fabdeacb9dca843e28fdd3b357711c5a84

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1275
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1275
This mail reflects revision 2 of this Change.

Acked-by according to Gerrit (reflected above):

src/openvpn/dco_freebsd.c +2 -2
index 947a769..f7ed02f 100644
@@ -621,8 +621,8 @@
             {
                 const nvlist_t *bytes = nvlist_get_nvlist(nvl, "bytes");
 
-                dco->dco_read_bytes = nvlist_get_number(bytes, "in");
-                dco->dco_write_bytes = nvlist_get_number(bytes, "out");
+                dco->c->c2.dco_read_bytes = nvlist_get_number(bytes, "in");
+                dco->c->c2.dco_write_bytes = nvlist_get_number(bytes, "out");
             }
 
             dco->dco_message_type = OVPN_CMD_DEL_PEER;
#4 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos, ralf_lici.

cron2 has posted comments on this change by ralf_lici. ( http://gerrit.openvpn.net/c/openvpn/+/1275?usp=email )

Change subject: dco-freebsd: store peer stats directly in c2
......................................................................

Patch Set 2: Code-Review-1

(2 comments)

Patchset:

PS2:
I think this needs more discussion on which counters on what event and in what mode (client side / CM_P2P vs. server side) to put where

File src/openvpn/dco_freebsd.c:

http://gerrit.openvpn.net/c/openvpn/+/1275/comment/4f9c725c_42b0c79e?usp=email :
PS2, Line 625: dco->c->c2.dco_write_bytes = nvlist_get_number(bytes, "out");
I don't think this is the correct place to store these.

The overall context here is "OVPN_NOTIF_DEL_PEER", so we're told by the kernel that dco->dco_message_peer_id went away, and, btw, here are the latest counters for this peer.

Storing it in dco->c->c2-> smells like "the server's global structure" while Linux would put per-client into dco->c->multi->instances[peer_id]->context.c2-> - OTOH, Linux' CMD_PEER_DEL_NTF seems to carry no counters, so the code is not the same anyway.

Am I misreading this?

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1275?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I53dd40fabdeacb9dca843e28fdd3b357711c5a84
Gerrit-Change-Number: 1275
Gerrit-PatchSet: 2
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ralf_lici <[email protected]...>
Gerrit-Comment-Date: Sat, 18 Oct 2025 17:01:34 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

#5 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos, ralf_lici.

ordex has posted comments on this change by ralf_lici. ( http://gerrit.openvpn.net/c/openvpn/+/1275?usp=email )

Change subject: dco-freebsd: store peer stats directly in c2
......................................................................

Patch Set 2:

(1 comment)

File src/openvpn/dco_freebsd.c:

http://gerrit.openvpn.net/c/openvpn/+/1275/comment/eaa99283_eaf32505?usp=email :
PS2, Line 625: dco->c->c2.dco_write_bytes = nvlist_get_number(bytes, "out");

Quoted 1 line

I don't think this is the correct place to store these. […]

actually if you check dco_update_peer_stat() it already does the right thing, similarly to what Gert is alluding to. Maybe this function can be re-used while parsing OVPN_NOTIF_DEL_PEER?

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1275?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I53dd40fabdeacb9dca843e28fdd3b357711c5a84
Gerrit-Change-Number: 1275
Gerrit-PatchSet: 2
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ralf_lici <[email protected]...>
Gerrit-Comment-Date: Sat, 18 Oct 2025 21:29:34 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>

#6 lore raw
In reply to a message not in the archive

Attention is currently required from: cron2, flichtenheld, plaisthos, ralf_lici.

Hello cron2, flichtenheld, plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1275?usp=email

to look at the new patch set (#3).

The following approvals got outdated and were removed:
Code-Review-1 by cron2

Change subject: dco-freebsd: store peer stats directly in c2
......................................................................

dco-freebsd: store peer stats directly in c2

The dco_context_t structure includes a reference to the general context structure c, which allows us to store dco_read_bytes and dco_write_bytes directly as c2 fields. This aligns the FreeBSD implementation with how we handle DCO peer stats on Linux and Windows.

Change-Id I53dd40fabdeacb9dca843e28fdd3b357711c5a84

---
M src/openvpn/dco_freebsd.c

1 file changed, 1 insertion(+), 4 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/75/1275/3

src/openvpn/dco_freebsd.c +1 -4
index 947a769..056430b 100644
@@ -619,10 +619,7 @@
 
             if (nvlist_exists_nvlist(nvl, "bytes"))
             {
-                const nvlist_t *bytes = nvlist_get_nvlist(nvl, "bytes");
-
-                dco->dco_read_bytes = nvlist_get_number(bytes, "in");
-                dco->dco_write_bytes = nvlist_get_number(bytes, "out");
+                dco_update_peer_stat(dco->c->multi, dco->dco_message_peer_id, nvlist_get_nvlist(nvl, "bytes"));
             }
 
             dco->dco_message_type = OVPN_CMD_DEL_PEER;

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1275?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I53dd40fabdeacb9dca843e28fdd3b357711c5a84
Gerrit-Change-Number: 1275
Gerrit-PatchSet: 3
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ralf_lici <[email protected]...>

#7 lore raw
In reply to a message not in the archive

Attention is currently required from: cron2, flichtenheld, ordex, plaisthos.

ralf_lici has posted comments on this change by ralf_lici. ( http://gerrit.openvpn.net/c/openvpn/+/1275?usp=email )

Change subject: dco-freebsd: store peer stats directly in c2
......................................................................

Patch Set 3:

(1 comment)

File src/openvpn/dco_freebsd.c:

http://gerrit.openvpn.net/c/openvpn/+/1275/comment/75cffd49_b9737742?usp=email :
PS2, Line 625: dco->c->c2.dco_write_bytes = nvlist_get_number(bytes, "out");

Quoted 1 line

actually if you check dco_update_peer_stat() it already does the right thing, similarly to what Ge […]

Yeah, you're right, the peer stats we're parsing here should go into the correct multi_instance context rather than the general server context. I went with Antonio's suggestion and reused dco_update_peer_stat(), which already handles this properly.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1275?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I53dd40fabdeacb9dca843e28fdd3b357711c5a84
Gerrit-Change-Number: 1275
Gerrit-PatchSet: 3
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Sun, 19 Oct 2025 08:37:49 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>
Comment-In-Reply-To: ordex <[email protected]...>

#8 lore raw
In reply to a message not in the archive

Attention is currently required from: cron2, flichtenheld, ordex, plaisthos.

Hello cron2, flichtenheld, plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1275?usp=email

to look at the new patch set (#4).

Change subject: dco-freebsd: store peer stats directly in c2
......................................................................

dco-freebsd: store peer stats directly in c2

The dco_context_t structure includes a reference to the general context structure c, which allows us to store dco_read_bytes and dco_write_bytes directly as c2 fields. This aligns the FreeBSD implementation with how we handle DCO peer stats on Linux and Windows.

Change-Id I53dd40fabdeacb9dca843e28fdd3b357711c5a84

---
M src/openvpn/dco_freebsd.c

1 file changed, 16 insertions(+), 19 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/75/1275/4

src/openvpn/dco_freebsd.c +16 -19
index 947a769..e51f8dd 100644
@@ -564,6 +564,21 @@
     return ret;
 }
 
+static void
+dco_update_peer_stat(struct multi_context *m, uint32_t peerid, const nvlist_t *nvl)
+{
+    if (peerid >= m->max_clients || !m->instances[peerid])
+    {
+        msg(M_WARN, "dco_update_peer_stat: invalid peer ID %d returned by kernel", peerid);
+        return;
+    }
+
+    struct multi_instance *mi = m->instances[peerid];
+
+    mi->context.c2.dco_read_bytes = nvlist_get_number(nvl, "in");
+    mi->context.c2.dco_write_bytes = nvlist_get_number(nvl, "out");
+}
+
 int
 dco_do_read(dco_context_t *dco)
 {
@@ -619,10 +634,7 @@
 
             if (nvlist_exists_nvlist(nvl, "bytes"))
             {
-                const nvlist_t *bytes = nvlist_get_nvlist(nvl, "bytes");
-
-                dco->dco_read_bytes = nvlist_get_number(bytes, "in");
-                dco->dco_write_bytes = nvlist_get_number(bytes, "out");
+                dco_update_peer_stat(dco->c->multi, dco->dco_message_peer_id, nvlist_get_nvlist(nvl, "bytes"));
             }
 
             dco->dco_message_type = OVPN_CMD_DEL_PEER;
@@ -777,21 +789,6 @@
     nvlist_destroy(nvl);
 }
 
-static void
-dco_update_peer_stat(struct multi_context *m, uint32_t peerid, const nvlist_t *nvl)
-{
-    if (peerid >= m->max_clients || !m->instances[peerid])
-    {
-        msg(M_WARN, "dco_update_peer_stat: invalid peer ID %d returned by kernel", peerid);
-        return;
-    }
-
-    struct multi_instance *mi = m->instances[peerid];
-
-    mi->context.c2.dco_read_bytes = nvlist_get_number(nvl, "in");
-    mi->context.c2.dco_write_bytes = nvlist_get_number(nvl, "out");
-}
-
 int
 dco_get_peer_stats_multi(dco_context_t *dco, const bool raise_sigusr1_on_err)
 {

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1275?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I53dd40fabdeacb9dca843e28fdd3b357711c5a84
Gerrit-Change-Number: 1275
Gerrit-PatchSet: 4
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>

#9 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, ordex, plaisthos, ralf_lici.

cron2 has posted comments on this change by ralf_lici. ( http://gerrit.openvpn.net/c/openvpn/+/1275?usp=email )

Change subject: dco-freebsd: store peer stats directly in c2
......................................................................

Patch Set 4: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1275?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I53dd40fabdeacb9dca843e28fdd3b357711c5a84
Gerrit-Change-Number: 1275
Gerrit-PatchSet: 4
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Attention: ralf_lici <[email protected]...>
Gerrit-Comment-Date: Sun, 19 Oct 2025 17:02:32 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

#10 lore raw

PATCH v4 1/1 dco-freebsd: store peer stats directly in c2

In reply to a message not in the archive

From: Ralf Lici <[email protected]...>

The dco_context_t structure includes a reference to the general context structure c, which allows us to store dco_read_bytes and dco_write_bytes directly as c2 fields. This aligns the FreeBSD implementation with how we handle DCO peer stats on Linux and Windows.

Change-Id I53dd40fabdeacb9dca843e28fdd3b357711c5a84

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1275
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1275
This mail reflects revision 4 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>

src/openvpn/dco_freebsd.c +16 -19
index 947a769..e51f8dd 100644
@@ -564,6 +564,21 @@
     return ret;
 }
 
+static void
+dco_update_peer_stat(struct multi_context *m, uint32_t peerid, const nvlist_t *nvl)
+{
+    if (peerid >= m->max_clients || !m->instances[peerid])
+    {
+        msg(M_WARN, "dco_update_peer_stat: invalid peer ID %d returned by kernel", peerid);
+        return;
+    }
+
+    struct multi_instance *mi = m->instances[peerid];
+
+    mi->context.c2.dco_read_bytes = nvlist_get_number(nvl, "in");
+    mi->context.c2.dco_write_bytes = nvlist_get_number(nvl, "out");
+}
+
 int
 dco_do_read(dco_context_t *dco)
 {
@@ -619,10 +634,7 @@
 
             if (nvlist_exists_nvlist(nvl, "bytes"))
             {
-                const nvlist_t *bytes = nvlist_get_nvlist(nvl, "bytes");
-
-                dco->dco_read_bytes = nvlist_get_number(bytes, "in");
-                dco->dco_write_bytes = nvlist_get_number(bytes, "out");
+                dco_update_peer_stat(dco->c->multi, dco->dco_message_peer_id, nvlist_get_nvlist(nvl, "bytes"));
             }
 
             dco->dco_message_type = OVPN_CMD_DEL_PEER;
@@ -777,21 +789,6 @@
     nvlist_destroy(nvl);
 }
 
-static void
-dco_update_peer_stat(struct multi_context *m, uint32_t peerid, const nvlist_t *nvl)
-{
-    if (peerid >= m->max_clients || !m->instances[peerid])
-    {
-        msg(M_WARN, "dco_update_peer_stat: invalid peer ID %d returned by kernel", peerid);
-        return;
-    }
-
-    struct multi_instance *mi = m->instances[peerid];
-
-    mi->context.c2.dco_read_bytes = nvlist_get_number(nvl, "in");
-    mi->context.c2.dco_write_bytes = nvlist_get_number(nvl, "out");
-}
-
 int
 dco_get_peer_stats_multi(dco_context_t *dco, const bool raise_sigusr1_on_err)
 {
#11 lore raw

[Openvpn-devel] [PATCH applied] Re: dco-freebsd: store peer stats directly in c2

Tested this, and it indeed does the right thing - the code in question is only called when a client exit is notified from the kernel (ping timeout, for example) and we do receive the proper value and put it into the correct place now :-)

(I have a patch in my FreeBSD-testing tree that logs all these counters)

Your patch has been applied to the master branch.

commit bf01a965dfbfc2651eaf3dbe4d37da74f3071628

Author: Ralf Lici
Date:   Sun Oct 19 19:02:42 2025 +0200
     dco-freebsd: store peer stats directly in c2

     Signed-off-by: Ralf Lici <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1275
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg33791.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#12 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#5) to the change originally created by ralf_lici. ( http://gerrit.openvpn.net/c/openvpn/+/1275?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2

Change subject: dco-freebsd: store peer stats directly in c2
......................................................................

dco-freebsd: store peer stats directly in c2

The dco_context_t structure includes a reference to the general context structure c, which allows us to store dco_read_bytes and dco_write_bytes directly as c2 fields. This aligns the FreeBSD implementation with how we handle DCO peer stats on Linux and Windows.

Change-Id I53dd40fabdeacb9dca843e28fdd3b357711c5a84

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1275
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg33791.html

---
M src/openvpn/dco_freebsd.c

1 file changed, 16 insertions(+), 19 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/75/1275/5

src/openvpn/dco_freebsd.c +16 -19
index 947a769..e51f8dd 100644
@@ -564,6 +564,21 @@
     return ret;
 }
 
+static void
+dco_update_peer_stat(struct multi_context *m, uint32_t peerid, const nvlist_t *nvl)
+{
+    if (peerid >= m->max_clients || !m->instances[peerid])
+    {
+        msg(M_WARN, "dco_update_peer_stat: invalid peer ID %d returned by kernel", peerid);
+        return;
+    }
+
+    struct multi_instance *mi = m->instances[peerid];
+
+    mi->context.c2.dco_read_bytes = nvlist_get_number(nvl, "in");
+    mi->context.c2.dco_write_bytes = nvlist_get_number(nvl, "out");
+}
+
 int
 dco_do_read(dco_context_t *dco)
 {
@@ -619,10 +634,7 @@
 
             if (nvlist_exists_nvlist(nvl, "bytes"))
             {
-                const nvlist_t *bytes = nvlist_get_nvlist(nvl, "bytes");
-
-                dco->dco_read_bytes = nvlist_get_number(bytes, "in");
-                dco->dco_write_bytes = nvlist_get_number(bytes, "out");
+                dco_update_peer_stat(dco->c->multi, dco->dco_message_peer_id, nvlist_get_nvlist(nvl, "bytes"));
             }
 
             dco->dco_message_type = OVPN_CMD_DEL_PEER;
@@ -777,21 +789,6 @@
     nvlist_destroy(nvl);
 }
 
-static void
-dco_update_peer_stat(struct multi_context *m, uint32_t peerid, const nvlist_t *nvl)
-{
-    if (peerid >= m->max_clients || !m->instances[peerid])
-    {
-        msg(M_WARN, "dco_update_peer_stat: invalid peer ID %d returned by kernel", peerid);
-        return;
-    }
-
-    struct multi_instance *mi = m->instances[peerid];
-
-    mi->context.c2.dco_read_bytes = nvlist_get_number(nvl, "in");
-    mi->context.c2.dco_write_bytes = nvlist_get_number(nvl, "out");
-}
-
 int
 dco_get_peer_stats_multi(dco_context_t *dco, const bool raise_sigusr1_on_err)
 {

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1275?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I53dd40fabdeacb9dca843e28fdd3b357711c5a84
Gerrit-Change-Number: 1275
Gerrit-PatchSet: 5
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>

#13 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1275?usp=email )

Change subject: dco-freebsd: store peer stats directly in c2
......................................................................

dco-freebsd: store peer stats directly in c2

The dco_context_t structure includes a reference to the general context structure c, which allows us to store dco_read_bytes and dco_write_bytes directly as c2 fields. This aligns the FreeBSD implementation with how we handle DCO peer stats on Linux and Windows.

Change-Id I53dd40fabdeacb9dca843e28fdd3b357711c5a84

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1275
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg33791.html

---
M src/openvpn/dco_freebsd.c

1 file changed, 16 insertions(+), 19 deletions(-)
src/openvpn/dco_freebsd.c +16 -19
index 947a769..e51f8dd 100644
@@ -564,6 +564,21 @@
     return ret;
 }
 
+static void
+dco_update_peer_stat(struct multi_context *m, uint32_t peerid, const nvlist_t *nvl)
+{
+    if (peerid >= m->max_clients || !m->instances[peerid])
+    {
+        msg(M_WARN, "dco_update_peer_stat: invalid peer ID %d returned by kernel", peerid);
+        return;
+    }
+
+    struct multi_instance *mi = m->instances[peerid];
+
+    mi->context.c2.dco_read_bytes = nvlist_get_number(nvl, "in");
+    mi->context.c2.dco_write_bytes = nvlist_get_number(nvl, "out");
+}
+
 int
 dco_do_read(dco_context_t *dco)
 {
@@ -619,10 +634,7 @@
 
             if (nvlist_exists_nvlist(nvl, "bytes"))
             {
-                const nvlist_t *bytes = nvlist_get_nvlist(nvl, "bytes");
-
-                dco->dco_read_bytes = nvlist_get_number(bytes, "in");
-                dco->dco_write_bytes = nvlist_get_number(bytes, "out");
+                dco_update_peer_stat(dco->c->multi, dco->dco_message_peer_id, nvlist_get_nvlist(nvl, "bytes"));
             }
 
             dco->dco_message_type = OVPN_CMD_DEL_PEER;
@@ -777,21 +789,6 @@
     nvlist_destroy(nvl);
 }
 
-static void
-dco_update_peer_stat(struct multi_context *m, uint32_t peerid, const nvlist_t *nvl)
-{
-    if (peerid >= m->max_clients || !m->instances[peerid])
-    {
-        msg(M_WARN, "dco_update_peer_stat: invalid peer ID %d returned by kernel", peerid);
-        return;
-    }
-
-    struct multi_instance *mi = m->instances[peerid];
-
-    mi->context.c2.dco_read_bytes = nvlist_get_number(nvl, "in");
-    mi->context.c2.dco_write_bytes = nvlist_get_number(nvl, "out");
-}
-
 int
 dco_get_peer_stats_multi(dco_context_t *dco, const bool raise_sigusr1_on_err)
 {

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1275?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I53dd40fabdeacb9dca843e28fdd3b357711c5a84
Gerrit-Change-Number: 1275
Gerrit-PatchSet: 5
Gerrit-Owner: ralf_lici <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>